unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Unit2, ExtCtrls;

type
  TFormTestServer = class(TForm)
    MemoReceive: TMemo;
    EditSend: TEdit;
    ButtonStart: TButton;
    ButtonSend: TButton;
    ButtonEnd: TButton;
    TimerLoad: TTimer;
    procedure ButtonStartClick(Sender: TObject);
    procedure ButtonEndClick(Sender: TObject);
    procedure ButtonSendClick(Sender: TObject);
    procedure TimerLoadTimer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  FormTestServer: TFormTestServer;
  Server: TServer;


implementation

{$R *.DFM}

procedure TFormTestServer.ButtonStartClick(Sender: TObject);
begin
     Server := TServer.create(100100);
     Server.Strings := TStringList.Create;
     ButtonStart.Enabled := false;
     TimerLoad.Enabled := true;
     ButtonSend.enabled := true;
     ButtonEnd.enabled := true;
end;

procedure TFormTestServer.ButtonEndClick(Sender: TObject);
begin
     Server.destroy;
     ButtonStart.enabled := true;
     TimerLoad.Enabled := false;
     ButtonSend.enabled := false;
     BUttonEnd.enabled := false;
end;

procedure TFormTestServer.ButtonSendClick(Sender: TObject);
begin
     Server.sendToAll(EditSend.text);
end;

procedure TFormTestServer.TimerLoadTimer(Sender: TObject);
begin
     if Server.Strings.Count > 0 then
     begin
          MemoReceive.Lines.add(Server.Strings[0]);
          Server.Strings.Delete(0);
     end;
end;

end.
